package com.pj.wisdomlogistics.ui.activity;

import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.view.View;

import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.cons.Cons;
import com.pj.wisdomlogistics.other.EventCenter;
import com.pj.wisdomlogistics.utils.ActivityManagerUtil;

import butterknife.OnClick;

public class SuccessActivity extends BaseActivity {

    private int takeoutId;
    private int meetingId;
    private int carId;
    private int repairId;
    private int mealId;

    @Override
    public void initView() {
        ultimateBar.setColorBar(ContextCompat.getColor(this , R.color.text_blue));
        takeoutId = getIntent().getIntExtra(Cons.TakeoutMeal.TAKEOUT_ID , -1);
        meetingId = getIntent().getIntExtra(Cons.MeetingInfo.MEETING_ID , -1);
        carId = getIntent().getIntExtra(Cons.CarInfo.CAR_ID , -1);
        repairId = getIntent().getIntExtra(Cons.RepairInfo.REPAIR_ID , -1);
        mealId = getIntent().getIntExtra(Cons.MealInfo.MEAL_ID , -1);
    }

    @Override
    public void initData() {

    }

    @Override
    public int getContentView() {
        return R.layout.activity_success;
    }

    @Override
    public boolean isApplyEventBus() {
        return false;
    }

    @Override
    public boolean isApplyButterKnife() {
        return true;
    }

    @Override
    public void onEventCome(EventCenter eventCenter) {

    }

    @OnClick({R.id.iv_back, R.id.bt_return, R.id.bt_detail})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                ActivityManagerUtil.create().finishActivity();
                break;
            case R.id.bt_return:
                startActivity(MainActivity.class);
                ActivityManagerUtil.create().finishActivity();
                break;
            case R.id.bt_detail:
                Intent mIntent = null;
                if(takeoutId != -1){
                    mIntent = new Intent(this , TakeoutDetailActivity.class);
                    mIntent.putExtra(Cons.TakeoutMeal.TAKEOUT_ID , takeoutId);
                }else if(meetingId != -1){
                    mIntent = new Intent(this , ApplyDetailActivity.class);
                    mIntent.putExtra(Cons.MeetingInfo.MEETING_ID , meetingId);
                }else if(carId != -1){
                    mIntent = new Intent(this , CarDetailActivity.class);
                    mIntent.putExtra(Cons.CarInfo.CAR_ID , carId);
                }else if(repairId != -1){
                    mIntent = new Intent(this , RepairDetailActivity.class);
                    mIntent.putExtra(Cons.RepairInfo.REPAIR_ID , repairId);
                }else if(mealId != -1){
                    mIntent = new Intent(this , MealDetialActivity.class);
                    mIntent.putExtra(Cons.MealInfo.MEAL_ID , mealId);
                }
                startActivity(mIntent);
                ActivityManagerUtil.create().finishActivity();
                break;
        }
    }
}
